package 空对象模式.java8Optional;

import java.util.Optional;

public class Main {
	public static void main(String[] args) {
		test1();
	}

	private static void test1() {
		Country china = new Country("china");
		Address address = new Address(china);
		// 良好的完整对象
		User user = new User(address);
		// 不好的null对象
		User nullUser = new User(null);
		User concreteUser = new User(new Address(new Country("china")));

		//具体对象编码的获取
		//String concreteIsocode = Optional.ofNullable(concreteUser)
				//.flatMap(u -> u.getAddress())
				//.flatMap(a -> a.getCountry())
				//.map(c -> c.getIsocode())
				//.orElse("暂无").toUpperCase();
	}
}
